package physics.shape;

import java.awt.Point;
import java.awt.Polygon;
import physics.Coordinate;

public class ObstaclePolygon extends Polygon implements ObstacleShape {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;

	
	/**
	 * standard constructor that makes a new empty ObstaclePolygon
	 */
	public ObstaclePolygon(){
		super();
	}
	
	
	/**
	 * constructor that makes a new ObstaclePolygon from an array of Coordinates
	 * @param points
	 * 			|the list of coordinates for the new ObstaclePolygon
	 */
	public ObstaclePolygon(Coordinate[] points){
		super();
		
		for (Coordinate coordinate : points) {
			this.addPoint((int)(coordinate.x),(int)(coordinate.y));
		}
	}
	
	
	/**
	 * 
	 * @return
	 * 		|a new ObstaclePolygon without the last point.
	 */
	public ObstaclePolygon getObstacleWithoutLastPoint(){
		ObstaclePolygon newPoly = new ObstaclePolygon();
		for (int i = 0; i < this.npoints; i++) {
			newPoly.addPoint(this.xpoints[i], this.ypoints[i]);
		}
		return newPoly;
	}
	
	
	@Override
	public boolean intersects(Circle circle) {
		return false;
		// TODO Auto-generated method stub

	}

	@Override
	public boolean contains(Circle circle) {
		for(int x : this.xpoints)
			for (int y : this.ypoints)
				if (Coordinate.getDistance(new Coordinate(x, y), circle.getCenter()) < circle.getRadius())
					return false;
		if (!this.contains(new Point((int) circle.getCenter().x, (int) circle.getCenter().y)))
			return false;
					return true;

	}

}
